home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / MuManual / Include / mmu / context.h < prev    next >
C/C++ Source or Header  |  2000-04-02  |  8KB  |  201 lines

  1. /*************************************************************************
  2.  ** mmu.library                                                         **
  3.  **                                                                     **
  4.  ** a system library for arbitration and control of the MC68K MMUs      **
  5.  **                                                                     **
  6.  ** © 1998 THOR-Software, Thomas Richter                                **
  7.  ** No commercial use, reassembly, modification without prior, written  **
  8.  ** permission of the authors.                                          **
  9.  ** Including this library in any commercial software REQUIRES a        **
  10.  ** written permission and the payment of a small fee.                  **
  11.  **                                                                     **
  12.  **---------------------------------------------------------------------**
  13.  ** context related definitions                                         **
  14.  **                                    **
  15.  ** $VER: 40.50 (31.10.99)                        **
  16.  *************************************************************************/
  17.  
  18. #ifndef MMU_CONTEXT_H
  19. #define MMU_CONTEXT_H
  20.  
  21. #ifndef EXEC_TYPES_H
  22. #include <exec/types.h>
  23. #endif
  24.  
  25. /* A context keeps roughly speaking an MMU table. Lovers of unix might
  26.    want to use the name "process" instead, whereas an exec task or
  27.    a dos.library process might be called "a thread".
  28.    All tasks sharing one context share one logical addressing space. */
  29.  
  30. /* The definition of the context structure: This is something you do
  31.    not care about. */
  32.  
  33. struct MMUContext {
  34.         struct MMUContext       *ctx_succ;      /* A doubly linked list */
  35.         struct MMUContext       *ctx_pred;
  36.         /* private data here. Do not touch, modify, .... */     
  37. };
  38.  
  39.  
  40. /* A mapping node, used to define the address space. This is what you find
  41.    in the list arbitrated by GetMapping().
  42.  
  43.    This structure is stricly READ ONLY */
  44.  
  45. struct MappingNode {
  46.         struct MappingNode     *map_succ;
  47.         struct MappingNode     *map_pred;
  48.         
  49.         ULONG            map_Lower;     /* lower address this node covers. */
  50.         ULONG            map_Higher;    /* higher address, inclusive */
  51.         ULONG            map_Flags;     /* internal use only. */
  52.         ULONG            map_Properties;        /* see below for definitions */
  53.         union {
  54.                 void    *map_UserData;  /* your data if this is invalid or swapped */
  55.                 void    *map_Page;      /* destination page if bundled */
  56.                 LONG    *map_Descriptor;/* pointer to a descriptor, alternatively */
  57.                 LONG    map_Delta;      /* added to the logical address if remapped */
  58.         }                map_un;
  59. };
  60.  
  61.  
  62.  
  63. /* Property types:
  64.    These define the "property flags" you may assign to memory with
  65.    SetProperties() and SetPageProperties(). */
  66.  
  67. #define MAPP_WRITEPROTECTED     (1<<2L)
  68. /* The region is write protected and the segmentation fault exception hooks 
  69.    will be called on a write access. */
  70.  
  71. #define MAPP_USED               (1<<3L)
  72. /* Set by the MMU on access, querried by GetPageProperties(). */
  73.  
  74. #define MAPP_MODIFIED           (1<<4L)
  75. /* Set by the MMU on write accesses, querried by GetPageProperties(). */
  76.  
  77. #define MAPP_CACHEINHIBIT       (1<<6L)
  78. /* Region is cache-inhibited, by default serialized access, precise
  79.    exception mode */
  80.  
  81. #define MAPP_SUPERVISORONLY     (1<<7L)
  82. /* Supervisor access only. Note that this is currently implemented by
  83.    marking the pages as invalid in the user MMU tables, not by setting
  84.    the supervisor bit. */
  85.  
  86. #define MAPP_USERPAGE0          (1<<8L)
  87. /* User page attribute 0, used only by 68040, 68060.
  88.    These bits are available at special pins of the CPU,
  89.    special hardware might require this. */
  90.  
  91. #define MAPP_USERPAGE1          (1<<9L)
  92. /* User page attribute 1 */
  93.  
  94. #define MAPP_GLOBAL             (1<<10L)
  95. /* This memory region is global. The MMU library makes currently no
  96.    effective use of this flag, and it makes only a difference for the
  97.    040 and 060 anyhow. */
  98.  
  99. #define MAPP_BLANK              (1<<11L)
  100. /* There's no memory here. If accessed, the access is quietly tolerated, 
  101.    even though nothing useful should be expected. This is mainly to work
  102.    around bad software if no enforcer is available. */
  103.  
  104. #define MAPP_SINGLEPAGE         (1<<12L)
  105. /* Give this page a private page descriptor. This flag IS A MUST
  106.    if you want to use GetPagePropertiesA/SetPagePropertiesA on
  107.    that page.  */
  108.  
  109. #define MAPP_COPYBACK           (1<<13L)
  110. /* MC68040 or MC68060 advanced copyback mode enabled. The library sets this
  111.    by default for all non-chip memory. */
  112.  
  113. #define MAPP_INVALID            (1<<14L)
  114. /* The page is invalid. Accessing it results in a segmentation fault, i.e.
  115.    the library will call the appropriate exception hooks. */
  116.  
  117. #define MAPP_REMAPPED           (1<<15L)
  118. /* Page is redirected to a different memory region. Note that you MUST NOT
  119.    add this memory to the exec library free memory list because some DMA
  120.    devices don't support I/O from this region and the MMU library will
  121.    guru as soon as you try to place MMU tables in remapped memory. 
  122.    This might change in the future. */
  123.  
  124. #define MAPP_SWAPPED            (1<<16L)
  125. /* This page is currently swapped out. If a program accesses this, a 
  126.    swapped-out fault is generated. UserData is available for a swapper 
  127.    daemon, usually the memory.library. */
  128.  
  129. #define MAPP_ROM                (1<<17L)
  130. /* This is read-only memory, but the library tolerates write accesses 
  131.    quietly and no hook is called on writes. Hence, this turns the memory
  132.    region effectively into a "ROM". */
  133.  
  134. #define MAPP_SHARED             (1<<18L)
  135. /* Shares the table of the global NULL context. This is currently not
  136.    implemented and should not be set. */
  137.  
  138. #define MAPP_TRANSLATED         (1<<19L)
  139. /* This memory region is - probably partially - under control of the 
  140.    transparent translation registers and should not be touched. 
  141.    The mmu library does not handle the transparent translation very well
  142.    and tries to get rid of them on startup. */
  143.  
  144. #define MAPP_REPAIRABLE         (1<<20L)
  145. /* This flag allows invalid or write protected pages to get repaired on
  146.    a fault by software rather than by swapping in a page. 
  147.    The mmu.library will try to make the written data available to the 
  148.    exception hook, and will try to provide readback data for the input 
  149.    pipeline of the CPU. Note that this is very useful for debugging tools 
  150.    and the like, but causes quite a lot of overhead.
  151.    Furthermore, MAPP_REPAIRABLE pages do not get user data. */
  152.  
  153. #define MAPP_IMPRECISE          (1<<21L)
  154. /* If non-cacheable, allow imprecise exception mode */
  155.  
  156. #define MAPP_INDIRECT           (1<<22L)
  157. /* Indirect table pointer to a user-provided table. Note that the mmu library
  158.    exception handler returns always a pointer to the descriptor pointing to
  159.    your descriptor, not to your descriptor directly. */
  160.  
  161. #define MAPP_BUNDLED            (1<<23L)
  162. /* Several pages bundled to one physical page in memory, usually done to 
  163.    map out memory. */
  164.  
  165. #define MAPP_USER0              (1<<24L)
  166. #define MAPP_USER1              (1<<25L)
  167. #define MAPP_USER2              (1<<26L)
  168. #define MAPP_USER3              (1<<27L)        
  169. /* Strictly for you. Not touched by the library. */
  170.  
  171. #define MAPP_NONSERIALIZED      (1<<29L)
  172. /* If non-cacheable, allow non-serialized access */
  173.  
  174. #define MAPP_IO               (1<<30L)
  175. /* I/O hardware. Avoid reading/writing this if you can avoid it. */
  176.  
  177.  
  178. /* error codes CreateMMUContext may generate: */
  179.  
  180. #define CCERR_TRIMMED           1    
  181. /* The MMU table has been trimmed to keep care about the enlarged 
  182.    table size. THIS IS NOT AN ERROR. */
  183.  
  184. #define CCERR_UNALIGNED             3    
  185. /* The MMU library had to perform some heavy rounding, as for
  186.    example to MAPP_REMAPPED pages. Therefore, the mapping 
  187.    might be partially wrong. You possibly do not want to use
  188.    this setup. */
  189.  
  190. #define CCERR_NO_FREE_STORE         103
  191. /* Out of memory. */
  192.  
  193. #define CCERR_INVALID_PARAMETERS    513
  194. /* Specified parameters are invalid. */
  195.  
  196. #define CCERR_UNSUPPORTED        514         
  197. /* The parameters are valid, but not supported by the 
  198.    available hardware. */
  199.  
  200. #endif
  201.